home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 July: Mac OS SDK / Dev.CD Jul 96 SDK / Dev.CD Jul 96 SDK1.toast / Development Kits (Disc 1) / OpenDoc / OpenDoc Development / Debugging Support / OpenDoc Source Code / Utilities / Interfaces / HshTbl.h < prev    next >
Encoding:
C/C++ Source or Header  |  1996-04-22  |  3.5 KB  |  129 lines  |  [TEXT/MPS ]

  1. /*
  2.     File:        HshTbl.h
  3.  
  4.     Contains:    AEHshTbl.h from C version of Apple Event Manager.
  5.  
  6.     Owned by:    Jon Pugh
  7.  
  8.     Copyright:    © 1993 - 1995 by Apple Computer, Inc., all rights reserved.
  9.  
  10. */
  11.  
  12. #ifndef __HshTbl__
  13. #define __HshTbl__
  14.  
  15. #ifndef __TYPES__
  16. #include <Types.h>
  17. #endif
  18.  
  19. // defines used in this code
  20. #define HUNLOCK(aHdl) HUnlock((Handle)aHdl)
  21. #define HLOCK(aHdl) HLock((Handle)aHdl)
  22. #define SETNOPURGE(aHdl) HNoPurge(aHdl)
  23. #define NEWHANDLE(size) NewHandleClear(size)
  24. #define NEWHANDLESYS(size) NewHandleSys(size)
  25. #define NEWHANDLESYSCLEAR(size) NewHandleSysClear(size)
  26. #define HANDTOHAND(handPtr) HandToHand((Handle  *)handPtr)
  27. #define GETHANDLESIZE(aHdl) GetHandleSize((Handle)aHdl)
  28. #define SETHANDLESIZE(aHdl, newSize) SetHandleSize((Handle)aHdl , newSize)
  29. #define DISPOSEHANDLE(aHdl) DisposeHandle((Handle)aHdl)
  30. #define DISPOSEPTR(p) DisposePtr(p)
  31. #define BLOCKMOVE(src,dst,count) BlockMove(src, dst, count)
  32. #define DEREF_OF(aHdl) *(Handle)aHdl
  33. #define CLEAR_REF_OF(aHdl)     // no need to do anything on Mac
  34. #define MACMEMFLAGS(flags) SignedByte flags
  35. #define GETSTATE(myHndl) HGetState((Handle)myHndl)
  36. #define RESET_HANDLE(myHndl,flags) HSetState((Handle)myHndl,flags)
  37. #define MEMERROR() MemError()
  38.  
  39. // error numbers 
  40.  
  41. #define ErrAlreadyExists  -1722            // fix this constant 
  42. #define      ErrNotFound  -1723            // fix this constant 
  43. #define      ErrEndOfTable  -1724            // fix this constant 
  44. #define      ErrNoHashTable  -1725                // used by NewHashTable
  45.  
  46. typedef Handle    HHand; 
  47. typedef Ptr        HEntryPtr;
  48. typedef Ptr        KeyPtr;
  49. //  typedef ProcPtr    HashProc;
  50.  
  51. typedef struct    MemProcBlock *    MemProcs; // ********  11/16 IS THIS USED??????
  52.  
  53. #if defined(powerc) || defined (__powerc)
  54. #pragma options align=mac68k
  55. #endif
  56. typedef struct    MemProcBlock {
  57.                         UniversalProcPtr        DerefProc;
  58.                         UniversalProcPtr        NewProc;
  59.                         UniversalProcPtr        GrowProc;
  60.                         UniversalProcPtr        DisposeProc;
  61.                     } MemProcBlock;
  62.  
  63. typedef struct    HashInfo {
  64.                         long        usedEntries;
  65.                         long        collidedEntries;
  66.                         long        totalEntries;
  67.                         long        tableSize;
  68.                     } HashInfo;
  69. #if defined(powerc) || defined(__powerc)
  70. #pragma options align=reset
  71. #endif
  72.  
  73. #if defined(powerc) || defined (__powerc)
  74. #pragma options align=mac68k
  75. #endif
  76. typedef struct    KeyRec {
  77.                 OSType        secondKey;
  78.                 OSType        firstKey;
  79.                 }KeyRec;
  80. #if defined(powerc) || defined (__powerc)
  81. #pragma options align=reset
  82. #endif
  83.  
  84. typedef KeyRec  * KeyRecPtr;
  85.  
  86. #if defined(powerc) || defined (__powerc)
  87. #pragma options align=mac68k
  88. #endif
  89. typedef struct    handlerRec {
  90.                     long        theRefCon;
  91.                     UniversalProcPtr        theProc;   // can be AEEventHandlerUPP or AECoerceDescUPP
  92.                     Boolean        IsSpecial;
  93.                     } handlerRec;
  94. #if defined(powerc) || defined (__powerc)
  95. #pragma options align=reset
  96. #endif
  97.  
  98. #ifdef __cplusplus
  99. extern "C" {
  100. #endif
  101.  
  102. OSErr NewHashTable(long NumEntries, short KeySize,short ValueSize,
  103.                                      MemProcs MemHooks,
  104.                                      Boolean     SysHeap,
  105.                                      HHand  * Table );
  106.                     
  107. OSErr DisposeHashTable(HHand *Hash, MemProcs MemHooks);
  108. OSErr ReplaceEntry(HHand Hash,MemProcs MemHooks,KeyPtr Key,HEntryPtr Value);
  109. OSErr RemoveKeyEntry(HHand Hash, MemProcs MemHooks,KeyPtr Key);
  110. OSErr GetKeyValue(HHand Hash, MemProcs MemHooks,KeyPtr Key,HEntryPtr Value);
  111. OSErr GetIndexedEntry(HHand Hash, MemProcs MemHooks, long Index, KeyPtr Key, HEntryPtr Value);
  112. Boolean    CheckKey(HHand Hash, MemProcs MemHooks,KeyPtr Key);
  113.  
  114.  
  115. /*    The following function is not implemented by AEHshTbl.C...but could just pass through to
  116.  *    ReplaceEntry.
  117.  *
  118.  *
  119. OSErr    AddKeyEntry(HHand Hash, MemProcs MemHooks,KeyPtr Key,HEntryPtr Value);
  120.  *
  121.  *
  122.  *
  123. */
  124.  
  125. #ifdef __cplusplus
  126. }
  127. #endif
  128.  
  129. #endif /* __HshTbl__ */